МІНІСТЕРСТВО ОСВІТИ І НАУКИ УКРАЇНИ
НАЦІОНАЛЬНИЙ УНІВЕРСИТЕТ «ЛЬВІВСЬКА ПОЛІТЕХНІКА»
ІКТА
З В І Т
до лабораторної роботи №4
з курсу: «Алгоритмічні мови та програмування»
на тему: «Основи Windows.Forms»
Мета роботи – навчитися створювати програми з графічним інтерфейсом. Вивчити бібліотеки Windows.Forms.
ЗАВДАННЯ
Написати довільну програму з графічним інтерфейсом, у якій реалізовані кнопки, меню, деякі прості функції та події.
СПИСОК ІДЕНТИФІКАТОРІВ КОНСТАНТ, ЗМІННИХ, ФУНКЦІЙ, ВИКОРИСТАНИХ У БЛОК-СХЕМІ АЛГОРИТМУ І ПРОГРАМІ, ТА ЇХ ПОЯСНЕННЯ
див. програму
ТЕКСТПРОГРАМИ
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Supper
{
public partial class Sapper : Form
{
int
FieldHeight,
FieldWight,
Mines,
W = 28,
H = 28;
int[,] Field;
private int FindMines;
private int FindFlags;
private int status;
private System.Drawing.Graphics g;
Rectangle rt;
System.Media.SoundPlayer click = new System.Media.SoundPlayer("Click.wav");
System.Media.SoundPlayer bomb = new System.Media.SoundPlayer("Bomb.wav");
System.Media.SoundPlayer tic = new System.Media.SoundPlayer("Tic.wav");
System.Media.SoundPlayer win = new System.Media.SoundPlayer("Win.wav");
bool soundcheck;
public Sapper()
{
InitializeComponent();
beginnerToolStripMenuItem.PerformClick();
click.Load();
bomb.Load();
tic.Load();
win.Load();
}
public void Start()
{
Field = new int[FieldHeight + 2, FieldWight + 2];
for (int row = 0; row <= FieldHeight + 1; row++)
{
Field[row, 0] = -3;
Field[row, FieldWight + 1] = -3;
}
for (int col = 0; col <= FieldWight + 1; col++)
{
Field[0, col] = -3;
Field[FieldHeight + 1, col] = -3;
}
this.ClientSize = new Size(W * FieldWight + 1, H * FieldHeight + MenuStrip.Height + 41);
newGame();
Restart();
}
public void Restart()
{
g = GameField.CreateGraphics();
int x = GameField.Size.Width / 2 - 25;
int y = H * FieldHeight + MenuStrip.Height - 23;
Point Loc = new Point(x, y);
SmileBox.Location = Loc;
SmileBox.Image = Image.FromFile("good.jpg");
MinetextBox.Location = new Point(2, H * FieldHeight + MenuStrip.Height - 20);
TimetextBox.Location = new Point(GameField.Width - 87, H * FieldHeight + MenuStrip.Height - 20);
TimetextBox.Font = new Font("Tahoma", 16);
TimetextBox.Text = "00:00:00";
}
public int MinesAround(int row, int col)
{
int k;
for (row = 1; row <= FieldHeight; row++)
for (col = 1; col <= FieldWight; col++)
if (Field[row, col] != 9)
{
k = 0;
if (Field[row - 1, col - 1] == 9) k++;
if (Field[row - 1, col] == 9) k++;
if (Field[row - 1, col + 1] == 9) k++;
if (Field[row, col - 1] == 9) k++;
if (Field[row, col + 1] == 9) k++;
if (Field[row + 1, col - 1] == 9) k++;
if (Field[row + 1, col] == 9) k++;
if (Field[row + 1, col + 1] == 9) k++;
Field[row, col] = k;
}
return Field[row, col];
}
pr...